$(function () {
    let companyId = localStorage.getItem("companyId");
    findByCompanyId(companyId);
});

function findByCompanyId(id) {
    let result = myAjax('/back/company/findByCompanyId','get',{id:id,token:$.cookie("token")});
    setCompanyData(result.companyModel);//需要给数据  把后台数据拿到
}

function setCompanyData(data) {
    $("#companyId").val(data.id);
    $("#companyName").val(data.companyName);
    $("#logo").val("");
    $("#ad").val(data.ad);
    $("#net").val(data.net);
    $("#introduce").val(data.introduce);
    $("#version").val(data.version);
}

function companyEdit() {
    let forData = new FormData();
    forData.append("companyId", $("#companyId").val());
    forData.append("companyName", $("#companyName").val());
    forData.append("logo", $("#logo")[0].files[0]);//文件取值
    forData.append("ad", $("#ad").val());
    forData.append("net", $("#net").val());
    forData.append("introduce", $("#introduce").val());
    forData.append("version", $("#version").val());
    forData.append("token",$.cookie("token"));
    let result = imgMyAjax('/back/company/companyEdit','post',forData);
    if (result.result === 1) {
        alert("提交成功");
        $("#right").load('/back/company/companyManage.html');
    } else {
        alert("提交失败")
    }
}
function cancelCompanyEdit() {
    $("#right").load('/back/company/companyManage.html');
}